home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume17 / morsecode < prev    next >
Encoding:
Internet Message Format  |  1989-02-06  |  3.7 KB

  1. Subject:  v17i081:  ASCII->Morse Code filter
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: mtymp01@ux.acss.umn.edu
  6. Posting-number: Volume 17, Issue 81
  7. Archive-name: morsecode
  8.  
  9. [  Kind of fun, useful for Boy Scouts and similar groups...   The
  10.   copyright seems kind of excessive.  --r$  ]
  11.  
  12. Morse takes the standard input and turns it in to international morse code.
  13. It doesn't know what to do with spaces, chars it doesn't know about
  14. it replaces with carrage returns. Also, it doesn't know about uppercase.
  15.  
  16. #! /bin/sh
  17. # This is a shell archive, meaning:
  18. # 1. Remove everything above the #! /bin/sh line.
  19. # 2. Save the resulting text in a file.
  20. # 3. Execute the file with /bin/sh (not csh) to create:
  21. #    Makefile
  22. #    morse.l
  23. #    morse.p
  24. export PATH; PATH=/bin:/usr/bin:$PATH
  25. if test -f 'Makefile'
  26. then
  27.     echo shar: "will not over-write existing file 'Makefile'"
  28. else
  29. cat << \SHAR_EOF > 'Makefile'
  30. DESTDIR=/usr/bin
  31. DESTMAN=/usr/man/manl
  32. all: morse
  33.  
  34. install: morse mandone
  35.     cp morse ${DESTDIR}
  36.  
  37. morse: morse.p
  38.     pc -o morse morse.p
  39.  
  40. mandone: morse.l
  41.     cp morse.l ${DESTMAN}
  42.     touch mandone
  43. SHAR_EOF
  44. fi
  45. if test -f 'morse.l'
  46. then
  47.     echo shar: "will not over-write existing file 'morse.l'"
  48. else
  49. cat << \SHAR_EOF > 'morse.l'
  50. .TH MORSE LOCAL "Jan 21, 1989" "UNIX User's Manual" ""
  51. .SH NAME
  52. morse \- translate standard input into international morse code.
  53. .SH SYNOPSIS
  54. morse
  55. .SH DESCRIPTION
  56. Morse takes the standard input and turns it in to international morse code.
  57. .SH BUGS
  58. Morse doesn't know what to do with spaces, chars it doesn't know about
  59. it replaces with carrage returns. Also, it doesn't know about uppercase.
  60. .SH AUTHOR
  61. Nils McCarthy
  62. .SH INTERNET.ADDRESS
  63. mtymp01@ux.acss.umn.edu, ...!rutgers!umn-cs!ux.acss!mtymp01
  64.  
  65. SHAR_EOF
  66. fi
  67. if test -f 'morse.p'
  68. then
  69.     echo shar: "will not over-write existing file 'morse.p'"
  70. else
  71. cat << \SHAR_EOF > 'morse.p'
  72. (*
  73.     THIS PROGRAM IS COPYRIGHT 1989 NILS MCCARTHY
  74.     ALL RIGHTS RESERVED INCLUFING THAT OF MODIFYING
  75.     THIS PROGRAM WITHOUT THE AUTHOR'S CONSENT.
  76.     
  77.     THIS PROGRAM MAY BE FREELY DISTRIBUTABLE PROVIDED
  78.     THIS HEADER IS KEPT WITH IT.
  79.  
  80.     Please send any and all comments to mtymp01@ux.acss.umn.edu,
  81.     if user mtymp01 unknown, please send to mccarthy@ux.acss.umn.edu
  82.     with subject 'To Nils', because that isn't my account.
  83.  
  84. *)
  85. program genmorse(input,output);
  86. var
  87.     let : char;
  88. begin
  89.     repeat
  90.         read(let);
  91.         case let of
  92.             'a' : write('.- ');
  93.             'b' : write('-... ');
  94.             'c' : write('-.-. ');
  95.             'd' : write('-..');
  96.             'e' : write('. ');
  97.             'f' : write('..-.');
  98.             'g' : write('--.');
  99.             'h' : write('....');
  100.             'i' : write('..');
  101.             'j' : write('.---');
  102.             'k' : write('-.-');
  103.             'l' : write('.-..');
  104.             'm' : write('--');
  105.             'n' : write('-.');
  106.             'o' : write('---');
  107.             'p' : write('.--.');
  108.             'q' : write('--.-');
  109.             'r' : write('.-.');
  110.             's' : write('...');
  111.             't' : write('-');
  112.             'u' : write('.--');
  113.             'v' : write('...-');
  114.             'w' : write('.--');
  115.             'x' : write('-..-');
  116.             'y' : write('-.--');
  117.             'z' : write('--..');
  118.             '1' : write('.----');
  119.             '2' : write('..---');
  120.             '3' : write('...--');
  121.             '4' : write('....-');
  122.             '5' : write('.....');
  123.             '6' : write('-....');
  124.             '7' : write('--...');
  125.             '8' : write('---..');
  126.             '9' : write('----.');
  127.             '0' : write('-----');
  128.             '.' : write('.-.-.-');
  129.             ',' : write('--..--');
  130.             '?' : write('..--..');
  131.             ':' : write('---...');
  132.             ';' : write('-.-.-.');
  133.         else
  134.             write(chr(10));
  135.         end;
  136.         write(' ');
  137.     until EOF(input);
  138.     writeln('.-.-.')
  139. end.
  140. SHAR_EOF
  141. fi
  142. exit 0
  143. #    End of shell archive
  144.  
  145. Thank you...
  146. also, if you want a comment, this is it:
  147. [Sorry, no readme. just edit Makefile to change destdir and mandir, then do
  148.                  make install and have everything happen.]
  149.  
  150.  
  151. ---Nils McCarthy---mtymp01@ux.acss.umn.edu---...!rutgers!umn-cs!ux.acss!mtymp01
  152.  
  153.